package Server;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import client.Login;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;
import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import ocsf.server.AbstractServer;
import ocsf.server.ConnectionToClient;

public class logoff {
	
	

	
	public static void chackusertologoff(Connection con1,String[] log )
	{
		
		DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
		Calendar cal = Calendar.getInstance();
		 try
         {
             Statement stmt = con1.createStatement(); 
     				stmt.executeUpdate("UPDATE users SET logged=0 WHERE username='"
     						+ log[3] + "'");
     				stmt.executeUpdate("UPDATE users SET logdate='"+dateFormat.format(cal.getTime())+"' WHERE username='"
     						+ log[3] + "'");

     	} catch (SQLException e) {
     		e.printStackTrace();
     	}
		
				
		
	}

}


